package com.yjck.fm.util;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import org.junit.Test;

import com.yjck.fm.spend.bean.SpendType;

public class DBUtilTest {

	@Test
	public void testDBUtil() {
		String sql = "SELECT id,spendname,createdby,createdate from spendtype where spendname like ?";
		DBUtil dbUtil = new DBUtil();
	//	dbUtil.getRs(sql, new Object[]{"购物"});
	//	dbUtil.getCount(sql,new Object[]{"购"});
	//	System.out.print(dbUtil.getCount(sql,new Object[]{"购"}));
	ResultSet rs = dbUtil.getRs(sql, new Object[]{"购"});
	int i = 1;
	try {
		while(rs.next()){
			System.out.println("------------"+rs.getString(i));
			i++;
		}
	} catch (SQLException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	
	List<Object> list = dbUtil.getList(sql, new Object[]{"购"}, new SpendType());
	for(Object obj:list){
		SpendType st = (SpendType)obj;
		System.out.println("id:"+st.getId());
		System.out.println("name:"+st.getName());
		System.out.println("creatby:"+st.getCreatby());
		System.out.println("time:"+st.getTime());
	}
	}
	
}
